# Impute covariates -------------------------------------------------------

covariate_frame <- ml[,covariates]

covariate_imp <- mice(data = covariate_frame,m = 1,seed = 1234567)
covariate_imp <- complete(covariate_imp)

ml[,covariates] <- covariate_imp[,covariates]

# Do it again 

covariate_frame <- ml[,covariates]

covariate_imp <- mice(data = covariate_frame,m = 1,seed = 1234567)
covariate_imp <- complete(covariate_imp)

ml[,covariates] <- covariate_imp[,covariates]

rm(covariate_frame,covariate_imp)

# Impute outcomes ---------------------------------------------------------

# absenteeism

absenteeism_frame <- ml[,absenteeism_outcomes]

absenteeism_imp <- mice(data = absenteeism_frame,m = 1,seed = 1234567)
absenteeism_imp <- complete(absenteeism_imp)

ml[,absenteeism_outcomes] <- absenteeism_imp[,absenteeism_outcomes]

rm(absenteeism_frame,absenteeism_imp)

# violence against women

# vaw

vaw_frame <- ml[, vaw_outcomes]

vaw_imp <- mice(data = vaw_frame, m = 1, seed = 1234567)
vaw_imp <- mice::complete(vaw_imp, action = 1)

ml[, vaw_outcomes] <- vaw_imp[, vaw_outcomes]

rm(vaw_frame, vaw_imp)

# abortion

abortion_frame <- ml[,abo_outcomes]

abortion_imp <- mice(data = abortion_frame,m = 1,seed = 1234567)
abortion_imp <- complete(abortion_imp)

ml[,abo_outcomes] <- abortion_imp[,abo_outcomes]

rm(abortion_frame,abortion_imp)
